package com.zmj.sy.mom.srv.aps.controller;

import cn.hutool.core.collection.CollUtil;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseResVo;
import com.zmj.sy.mom.srv.aps.service.DxfService;
import com.zmj.sy.mom.srv.aps.service.SinoCamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RequiredArgsConstructor
@Api(tags = "DXF图纸管理")
@RestController
@RequestMapping("/dxf")
public class DxfController {

    private final DxfService dxfService;

    private final SinoCamService sinoCamService;

    @ApiOperation("执行同步")
    @GetMapping("/exec")
    public BaseResVo exec() {
        List<Integer> exec = dxfService.exec();

        if (CollUtil.isEmpty(exec)) {
            return BaseResVo.ok();
        }

//        for (Integer id : exec) {
//            PushNestVo rr = new PushNestVo();
//            rr.setId(id);
//            sinoCamService.pushNest(rr);
//        }

        return BaseResVo.ok();
    }

    @ApiOperation("用零件图号定时查询MES返回零件图纸")
    @PostMapping("/getPngByPlmId")
    public void getPngByPlmId() throws IOException {
        dxfService.getPngByPlmId();
    }

    @ApiOperation("定时同步零件信息到OrderPart表")
    @PostMapping("/fillOrderPart")
    public void fillOrderPart() {
        dxfService.fillOrderPart();
    }

//    @ApiOperation("查询check表状态为0的数据，进行套料信息处理")
//    @PostMapping("/checkNestZeroInfo")
//    public void checkNestZeroInfo() {
//        dxfService.checkNestZeroInfo();
//    }

    @ApiOperation("定时处理未切割报工钢板套料数据")
    @PostMapping("/checkPlateNestInfo")
    public void checkPlateNestInfo() {
        dxfService.checkPlateNestInfo();
    }

}
